package com.msmall.community.user.service;

import java.io.File;
import java.util.List;

import com.msmall.base.model.OperationResult;
import com.msmall.base.pager.PaginationSupport;
import com.msmall.base.service.BaseManager;
import com.msmall.community.user.model.LoginInfo;
import com.msmall.community.user.model.UserInfo;
import com.msmall.community.user.model.UserProfile;
import com.msmall.community.user.model.UserSetting;

public interface UserManager extends BaseManager{
	
	/**
	 * 创建一个匿名账号,放入缓存,仅创建UserInfo的部分信息：userid username nickname
	 */
	public UserInfo createAnonymousAccount(Long userid, String username);
	/**
	 * 删除创建的匿名账号；从缓存删除
	 */
	public void removeAnonymousAccount(Long userid);
	
	public OperationResult authenticate(String username, String passwd);

	/**
	 * false:此用户不存在
	 */
	public boolean isUsernameExisted(String username);
	/**
	 * 通过用户昵称查找用户
	 */
	public void getPagination(PaginationSupport page, String nickname);
	
	/**
	 * 通过性别，年龄段查找用户
	 * agesmin <= agesmax
	 */
	public void getPagination(PaginationSupport page, Short gender, Integer agesmax, Integer agesmin);
	/**
	 * like
	 * @throws Exception 
	 */
	public List<UserInfo> getByNickname(String nickname);
	
	public boolean register(UserInfo userInfo);
	
	/**
	 * 先从缓存获得
	 */
	public UserInfo getByUsername(String username);
	/**
	 * 先从缓存获得
	 */
	public UserInfo getByUserid(Long userid);
	/**
	 * 先从缓存获得
	 */
	public UserProfile getProfileByUserid(Long userid);
	/**
	 * 更新缓存
	 */
	public UserInfo saveAvatar(File avatar,String filename, String uat, Long userid);
	/**
	 * 更新缓存
	 */
	public UserInfo saveUserInfo(UserInfo userInfo);
	/**
	 * 当用户退出时，修改退出时间
	 * @param userid
	 */
	public void updateLogoutInfo(Long userid);
	/**
	 * 添加登陆信息
	 */
	public void addLoginInfo(LoginInfo login);
	
	/**
	 * 获得用户的所有设置信息等
	 * @param userid
	 * @return
	 */
	public List<UserSetting> getSettingByUserid(Long userid);
	
	public UserSetting getSetting(Long settingid);
	
	/**
	 * key : ConstantDB.USER_SETTING_KEY_
	 */
	public UserSetting getSetting(Long userid, String key);
	
	public UserSetting saveSetting(Long userid, String key, String value);
	
	/**
	 * 添加用户的回复贴数量，每次加1
	 * @param userid
	 */
	public void addThreadAmount(Long userid);
	
	/**
	 * 添加用户的主题帖数量，每次加1
	 * @param userid
	 */
	public void addTopicAmount(Long userid);
	/**
	 * 添加用户的精华帖数量，每次加1
	 * @param userid
	 */
	public void addEliteAmount(Long userid);
	/**
	 * 减少用户的精华帖数量，每次减1
	 * @param userid
	 */
	public void reduceEliteAmount(Long userid);
	
	/**
	 * 添加用户的日记数量，每次加1
	 * @param userid
	 */
	public void addDiaryAmount(Long userid);
	
	/**
	 * 添加用户的相册数量，每次加1
	 * @param userid
	 */
	public void addAlbumAmount(Long userid);
	
	/**
	 * 添加用户的好友数量，每次加1
	 * @param userid
	 */
	public void addRosterAmount(Long userid);
	
	/**
	 * 添加用户的空间访问数量，每次加1
	 * @param userid
	 */
	public void addVisitAmount(Long userid);
}
